/**
 * Copyright (C) 2017 - 2020 https://github.com/joewee
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.entity;

import com.bifrost.uid.worker.WorkerNodeType;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * uid-generator 使用
 *
 * @author joewee
 * @version 1.0.0
 * @Date 2017/11/20 20:01
 */
@Entity
@Table(name = "WORKER_NODE")
@NamedQuery(name = "WorkerNode.findAll", query = "SELECT c FROM WorkerNode c")
public class WorkerNode implements Serializable {
    private static final long serialVersionUID = 7820077176903105190L;
    /**
     * Entity unique id (table unique)
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    /**
     * Type of CONTAINER: HostName, ACTUAL : IP.
     */
    @Column(name = "HOST_NAME")
    private String hostName;

    /**
     * Type of CONTAINER: Port, ACTUAL : Timestamp + Random(0-10000)
     */
    @Column(name = "PORT")
    private String port;

    /**
     * type of {@link WorkerNodeType}
     */
    @Column(name = "TYPE")
    private int type;

    /**
     * Worker launch date, default now
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "LAUNCH_DATE")
    private Date launchDate = new Date();

    /**
     * Created time
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CREATED")
    private Date created = new Date();

    /**
     * Last modified
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "MODIFIED")
    private Date modified = new Date();

    /**
     * Getters & Setters
     */
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Date getLaunchDate() {
        return launchDate;
    }

    public void setLaunchDateDate(Date launchDate) {
        this.launchDate = launchDate;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getModified() {
        return modified;
    }

    public void setModified(Date modified) {
        this.modified = modified;
    }

}
